#!/bin/bash

echo "Running..."

while :
do
	

id=`pidof -s gdb`
inf_id=`pidof -s a.out`

if [ "$id" != "" ]
then
	status=`cat /proc/$id/wchan`
fi

suspend_stat="sys_rt_sigsuspend"
stop_stat="ptrace_stop"

if [ "$status" = "$suspend_stat" ]
then
	inf_status=`cat /proc/$inf_id/wchan`

	if [ "$inf_status" = "$stop_stat" ]
	then
		#yeah, suspended, we tell it to continue
		echo "reviving gdb"
		kill -s SIGCONT $id
	fi
fi



done
